package com.briup.ch09;

import java.util.Scanner;

/**
 * @Author briup-adam
 * @Date 2023/10/18 上午9:32
 * @Description
 **/

public class LoginTest {
    public  static String  login(String name,String password) throws LoginException {
        if (!name.equals("briup"))
            throw new  LoginException("用户不存在");
        else if(!password.equals("briup")){
            throw new  LoginException("用户名密码错误");
        }else {
            return  "ok";
        }
    }

    public static void main(String[] args) {
        //完成用户登录的逻辑
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = sc.next();
        System.out.println("请输入密码：");
        String password = sc.next();
        try {
            String login = login(name, password);
            System.out.println(login);
        } catch (LoginException e) {
            System.err.println(e.getMessage());
        }
    }
}
